package net.swl.linkedvillage;

import com.parse.ParseException;//e
import com.parse.ParseUser;
import com.parse.SaveCallback;

import net.swl.linkedvillage.entity.User;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class EditarPerfilActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_editar_perfil);
		getActionBar().setIcon(R.drawable.logo_linkedvillage);
		setTitle("");
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.editar_perfil, menu);//
		return true;
	}
	
	public void onGuardarClick(View v) {
		User user = new User(ParseUser.getCurrentUser());
		
		EditText txt = (EditText) findViewById(R.id.perfilEmail);
		user.setEmail(txt.getText().toString());
		
		txt = (EditText) findViewById(R.id.perfilNome);
		user.setNome(txt.getText().toString());

		txt = (EditText) findViewById(R.id.perfilPassword);
		user.setPassword(txt.getText().toString());
		
		txt = (EditText) findViewById(R.id.perfilMorada);
		user.setMorada(txt.getText().toString());
		
		txt = (EditText) findViewById(R.id.perfilTelefone);
		user.setTelefone(txt.getText().toString());
		
		user.getParseObject().saveInBackground(new SaveCallback() {
			
			@Override
			public void done(ParseException arg0) {
				Log.i(EditarPerfilActivity.class.getSimpleName(), "Perfil guardado");
			}
		});
		
	}

}
